﻿<%@ Page Language="C#" MasterPageFile="~/Theme/Stander/Stander.master" AutoEventWireup="true" CodeFile="Media.aspx.cs" Inherits="Media_Media" Title="Untitled Page" %>
<%@ Register Src="../User Controls/ContactListControl.ascx" TagName="ContactListControl"
    TagPrefix="uc1" %>
<%@ Import Namespace="Active.Core" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h2>媒介信息</h2>
<asp:DetailsView ID="MediaDetailsView" runat="server"
    AutoGenerateRows="False" DataKeyNames="Id" DataSourceID="MediaDataSource"
    OnItemInserted="MediaDetailsView_ItemInserted" OnDataBound="MediaDetailsView_DataBound" OnItemInserting="MediaDetailsView_ItemInserting" OnItemUpdating="MediaDetailsView_ItemUpdating">
    <Fields>
        <asp:TemplateField HeaderText="所属区域" SortExpression="RegionId">
            <EditItemTemplate>
                <asp:DropDownList ID="ddlRegions" runat="server" DataTextField="Name" DataValueField="Id"
                    DataSource='<%# Regions.GetRegions() %>'>
                </asp:DropDownList>
            </EditItemTemplate>
            <InsertItemTemplate>
                <asp:DropDownList ID="ddlRegions" runat="server" DataTextField="Name" DataValueField="Id"
                    DataSource='<%# Regions.GetRegions() %>'>
                </asp:DropDownList>
            </InsertItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label1" runat="server" 
                    Text='<%# Regions.GetRegions().GetRegionById((int)Eval("RegionId")).Name %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="类型" SortExpression="Category">
            <EditItemTemplate>
                <asp:DropDownList ID="ddlMediaTypes" runat="server">
                    <asp:ListItem Text="电视媒体" Value="1"></asp:ListItem>
                    <asp:ListItem Text="刊物(报纸,杂志等)" Value="0"></asp:ListItem>
                </asp:DropDownList>
            </EditItemTemplate>
            <InsertItemTemplate>
                <asp:DropDownList ID="ddlMediaTypes" runat="server">
                    <asp:ListItem Text="电视媒体" Value="1"></asp:ListItem>
                    <asp:ListItem Text="刊物(报纸,杂志等)" Value="0"></asp:ListItem>
                </asp:DropDownList>
            </InsertItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label2" runat="server" Text='<%# Bind("Category") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="名称：">
            <InsertItemTemplate>
                <asp:TextBox id="txtName" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
                <asp:Label ID="lblNameError" runat="server" Text="" CssClass="error"></asp:Label>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" SetFocusOnError="true" 
                    runat="server" ErrorMessage="*" ControlToValidate="txtName">
                </asp:RequiredFieldValidator>
            </InsertItemTemplate>
            <EditItemTemplate>
                <asp:TextBox id="txtName" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
                <asp:Label ID="lblNameError" runat="server" Text="" CssClass="error"></asp:Label>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" SetFocusOnError="true" 
                    runat="server" ErrorMessage="*" ControlToValidate="txtName">
                </asp:RequiredFieldValidator>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:TextBox id="txtName" runat="server" Text='<%# Bind("Name") %>' ReadOnly="true"></asp:TextBox>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="Tel" HeaderText="电话：" SortExpression="Tel" />
        <asp:BoundField DataField="Fax" HeaderText="传真：" SortExpression="Fax" />
        <asp:TemplateField HeaderText="地址：">
            <InsertItemTemplate>
                <asp:TextBox id="txtAdress" runat="server" CssClass="long" 
                    TextMode="MultiLine" Rows="3" Text='<%# Bind("Address") %>'></asp:TextBox>
            </InsertItemTemplate>
            <EditItemTemplate>
                <asp:TextBox id="txtAdress" runat="server" CssClass="long" 
                    TextMode="MultiLine" Rows="3" Text='<%# Bind("Address") %>'></asp:TextBox>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:TextBox id="txtAdress" runat="server" CssClass="long" ReadOnly="true"
                    TextMode="MultiLine" Rows="3" Text='<%# Bind("Address") %>'></asp:TextBox>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="频道" SortExpression="Channels">
            <EditItemTemplate>
                <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Channels") %>'
                    TextMode="MultiLine" Rows="8"></asp:TextBox>
            </EditItemTemplate>
            <InsertItemTemplate>
                <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Channels") %>'
                    TextMode="MultiLine" Rows="8"></asp:TextBox>
            </InsertItemTemplate>
            <ItemTemplate>
                <asp:TextBox id="txtAdress" runat="server" ReadOnly="true"
                    TextMode="MultiLine" Rows="8" Text='<%# Bind("Channels") %>'></asp:TextBox>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="DealTimes" HeaderText="交易次数：" InsertVisible="False" ReadOnly="True" 
            SortExpression="DealTimes" />
        <asp:HyperLinkField DataNavigateUrlFields="Id" ItemStyle-CssClass="right" InsertVisible="False"
            DataNavigateUrlFormatString="~/Media/MediaAdvances.aspx?id={0}"
            DataTextField="Advance" DataTextFormatString="{0:c}" HeaderText="剩余预付款" />
        <asp:HyperLinkField DataNavigateUrlFields="Id" ItemStyle-CssClass="right" InsertVisible="False"
            DataNavigateUrlFormatString="~/Media/MediaBrokerages.aspx?id={0}"
            DataTextField="Brokerage" DataTextFormatString="{0:c}" HeaderText="剩余返点" />
        <asp:TemplateField>
            <InsertItemTemplate>
                <asp:Button ID="Button1" CommandName="Insert" runat="server" Text="添加" />
            </InsertItemTemplate>
            <EditItemTemplate>
                <asp:Button ID="Button1" CommandName="Update" runat="server" Text="更新" />
            </EditItemTemplate>
            <ItemTemplate></ItemTemplate>
        </asp:TemplateField>
    </Fields>
</asp:DetailsView>
<csla:CslaDataSource ID="MediaDataSource" runat="server" 
    TypeName="Active.Core.Media, Active.Core" OnDeleteObject="MediaDataSource_DeleteObject"
    OnInsertObject="MediaDataSource_InsertObject" OnSelectObject="MediaDataSource_SelectObject"
    OnUpdateObject="MediaDataSource_UpdateObject" 
    TypeSupportsPaging="False" TypeSupportsSorting="False">
</csla:CslaDataSource>
<uc1:ContactListControl id="ContactListControl1" runat="server">
</uc1:ContactListControl>
</asp:Content>

